<%@ page import="java.util.*" language="java"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="css/basic.css" type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
	function showTime() {
		var time = new Date();
		document.getElementById("ti").innerHTML = time;
		setTimeout("systemTime()", 1000);
	}
	function firm() {
		if (confirm("确定要删除此博客？"))
			return true;
		else
			return false;
	}
</script>
<title>个人空间</title>
</head>
<c:if test="${admin==null }">
	<c:redirect url="login.jsp"></c:redirect>
</c:if>
<body style="background-color: linen; text-align: center"
	onload="showTime()">
	<div class="top">
		<a href="home.jsp"><button>主页</button></a><a
			href="BlogEdit?action=show"><button>我的博客</button></a> <a
			href="writeblog.jsp"><button>上传博客</button></a> <a href="userinfo.jsp"><button>${pass}</button></a>
		<a href="Login?action=leave"><button>退出登录</button></a>
	</div>
	<h2 style="text-align: center">${pass.name }的博客</h2>
	<!-- 列出本人全部博客的标题 -->

	<form action="BlogEdit" method="get">
		搜索博客:<input type="text" name="key"> <input type="hidden"
			value="keys" name="action"> <input type="submit">
	</form>

	<div align="center">
		<c:set var="pagesize" value="10" scope="page" />
		<!--记录数 -->
		<c:set var="number" value="${titles.size()}" scope="page" />
		<!-- 计算分页数 -->
		<c:set var="pagenumber" value="${param.start/pagesize+1}" />

		<table class="ta">
			<tr>
				<th width="220px">标题</th>
				<th width="178px">上传时间</th>
				<th>操作</th>
				<!-- 	<td colspan="3" align="center"></td> -->
			</tr>
			<!--判断是否有信息  -->
			<!-- 如果类别为空  otherwise -->
			<c:choose>
				<c:when test="${empty titles}">
				</c:when>
				<c:otherwise>
					<c:forEach items="${titles}" var="row" begin="${param.start}"
						end="${param.start+pagesize-1}">
						<tr>
							<td>${row.title}</td>
							<td
								style="height: 30px; white-space: nowrap; word-spacing: 24px; overflow: hidden;">${row.time}</td>
							<td><a href="BlogEdit?action=readBlog&id=${row.id }">阅读</a></td>
							<td align="left"><a
								href="BlogEdit?action=change&id=${row.id }">修改</a>&emsp;&emsp;<a
								onclick="return firm()"
								href="BlogEdit?action=delete&id=${row.id }">删除</a></td>
						</tr>
					</c:forEach>
				</c:otherwise>
			</c:choose>
		</table>
		<br> <br>
		<!--分页  -->
		<c:choose>
			<c:when test="${param.start>9}">
				<a href="home.jsp?start=${param.start-pagesize}">上一页</a>
			</c:when>
			<c:otherwise>
         首页
   </c:otherwise>
		</c:choose>
		<!-- 显示分页数 -->
		第<font color="red">${pagenumber}"</font>页
		<c:choose>
			<c:when test="${param.start+pagesize<number}">
				<a href="home.jsp?start=${param.start+pagesize}">下一页</a>
			</c:when>
			<c:otherwise>
	尾页
   </c:otherwise>
		</c:choose>

		<!-- 显示记录数 -->
		共<font color="red">${number}</font>条记录 &nbsp;

	</div>

	<br />
	<br>
	<br>
	<p id="ti" style="text-align: center;"></p>
</body>
</html>